home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.StringItem;
-
- class Roger$AnimationCanvas extends Canvas implements Runnable {
- int currentImg;
- Roger$AnimationCanvas$BallsEngine ballsEngine;
- boolean goOn;
- // $FF: renamed from: t java.lang.Thread
- Thread field_0;
- int minX;
- int maxX;
- // $FF: renamed from: x int
- int field_1;
- // $FF: renamed from: y int
- int field_2;
- long start;
- boolean end;
- // $FF: synthetic field
- private final Roger this$0;
-
- Roger$AnimationCanvas(Roger this$0) {
- this.this$0 = this$0;
- this.currentImg = 0;
- this.goOn = true;
- this.field_0 = null;
- this.ballsEngine = new Roger$AnimationCanvas$BallsEngine(this);
- Roger.access$1402(this$0, ((Canvas)this).getWidth());
- Roger.access$1502(this$0, ((Canvas)this).getHeight());
- this.minX = 0;
- this.maxX = Roger.access$1400(this$0) - 20;
- }
-
- void init() {
- this.field_1 = Roger.access$1400(this.this$0) / 2 - 10;
- this.field_2 = Roger.access$1500(this.this$0) - 1;
- System.out.println("within init() x=" + this.field_1 + " y=" + this.field_2 + " width=" + Roger.access$1400(this.this$0) + " height=" + Roger.access$1500(this.this$0));
- }
-
- public void run() {
- System.out.println("start of the run() method");
-
- while(this.goOn) {
- ((Canvas)this).repaint();
- ((Canvas)this).serviceRepaints();
- this.ballsEngine.tick();
-
- try {
- Thread.sleep(150L);
- } catch (Exception var2) {
- ((Throwable)var2).printStackTrace();
- }
- }
-
- System.out.println("end of the run loop within the run() method");
- Roger.access$600(this.this$0).append(new StringItem("score", " " + (System.currentTimeMillis() - this.start) / 1000L));
- Roger.access$1200(this.this$0).setCurrent(Roger.access$600(this.this$0));
- System.out.println("end of run()");
- }
-
- void startAnimation() {
- this.ballsEngine.init(Roger.access$1400(this.this$0), Roger.access$1500(this.this$0));
- this.start = System.currentTimeMillis();
- this.end = false;
- this.goOn = true;
- if (this.field_0 == null) {
- this.field_0 = new Thread(this);
- this.field_0.start();
- }
-
- }
-
- void stopAnimation() {
- this.goOn = false;
- this.field_0 = null;
- }
-
- protected void keyPressed(int keyCode) {
- System.out.println("within the keyPressed");
- switch (((Canvas)this).getGameAction(keyCode)) {
- case 2:
- this.left();
- break;
- case 5:
- this.right();
- }
-
- }
-
- void left() {
- if (this.field_1 > 4) {
- this.field_1 -= 5;
- }
-
- }
-
- void right() {
- if (this.field_1 < Roger.access$1400(this.this$0) - 24) {
- this.field_1 += 5;
- }
-
- }
-
- public void paint(Graphics g) {
- System.out.println("within paint x=" + this.field_1 + " y=" + this.field_2);
- g.setGrayScale(255);
- g.fillRect(0, 0, Roger.access$1400(this.this$0), Roger.access$1500(this.this$0));
- g.drawImage(Roger.access$000(this.this$0)[this.currentImg], this.field_1, this.field_2, 36);
- Location[] locations = this.ballsEngine.getLocations();
- g.setGrayScale(0);
-
- for(int i = 0; i < locations.length; ++i) {
- g.fillArc(locations[i].x, locations[i].y, 10, 10, 0, 360);
- if ((locations[i].x < this.field_1 && locations[i].x > this.field_1 - 10 || locations[i].x > this.field_1 && locations[i].x < this.field_1 + 20) && locations[i].y < this.field_2 && locations[i].y > this.field_2 - 25) {
- this.end = true;
- this.goOn = false;
- this.stopAnimation();
- }
- }
-
- ++this.currentImg;
- if (this.currentImg > 5) {
- this.currentImg = 0;
- }
-
- }
- }
-